package com.zyz.F_异常.练习1;

import java.util.Scanner;

/**
 * @author: vick
 * @Date: 2025/3/18
 * @Description:
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {

        try {
            System.out.println("请输入一个正整数:");
            Scanner scanner = new Scanner(System.in);

            int i = scanner.nextInt();
            if (i < 0) {
                throw new MyNumberException("请输入一个正整数");
            }
            System.out.println("输入的是：" +  i);
        }catch (Exception e) {
            throw new MyNumberException("请输入一个有效的数字");
        }
    }
}
